function N = growMatrix(M,new_dim_order)
% evenly distribute square matrix M from current dimensions (old_dim) 
% to square matrix N of new dimensions (new_dim).
% i.e. 5x5 -> 17x17 
new_dim = 2^new_dim_order;
old_dim = length(M(1,:));
old_dim_order = log2(old_dim-1);
N = zeros(new_dim)+inf; % Preallocate matrix to inf (inf is terrain code)
if (new_dim > old_dim)
	step = 2^(new_dim_order - old_dim_order); % i.e.(4-2 = 2 steps)

	for m = 1:old_dim
		for n = 1:old_dim
			N((m-1)*step+1,(n-1)*step+1) = M(m,n)*step; % increase altitude to maintain dist/alt ratio
		end
	end
end
return;
